module.exports = () => {
    return async (ctx,next) => {
        //1.获取请求的接口，区分是否需要鉴权
        console.log("====",ctx.path);
        //ctx.request.path
        let writePath = ['/api/list'];
        if(writePath.includes(ctx.path)){
            //不需要鉴权
            await next();
        }else{
            //需要鉴权
            // console.log(ctx.request.headers['egg-identity'])
            let identity = ctx.get('egg-identity');
            if(identity && identity === 'admin'){
                //符合条件的
                await next();
            }else{
                //不符合条件
                ctx.body = {msg:"无权限", status:401}
            }
        }
    }
}